//
//  StatusCellBottomView.swift
//  Weibo8023
//
//  Created by styshy on 15/12/11.
//  Copyright © 2015年 sz. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    /// 转发
    private lazy var retweeted_status:UIButton = UIButton(title: "转发", fontSize: 12,color: UIColor.whiteColor(), imageName: "timeline_icon_retweet")
    
    /// 评论
    private lazy var comments_count:UIButton = UIButton(title: "评论",  fontSize: 12,color:UIColor.whiteColor(), imageName: "timeline_icon_comment")
    
    /// 赞
    private lazy var reposts_count:UIButton = UIButton(title: "赞",  fontSize: 12,color:UIColor.whiteColor(), imageName: "timeline_icon_unlike")

}

/// 设置布局
extension StatusCellBottomView{
    
    private func setupUI(){
//        self.backgroundColor = UIColor.darkGrayColor()
        self.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        
        addSubview(retweeted_status)
        addSubview(comments_count)
        addSubview(reposts_count)
        
        // 设置自动布局
        retweeted_status.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        comments_count.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweeted_status.snp_top)
            make.left.equalTo(retweeted_status.snp_right)
            make.bottom.equalTo(retweeted_status.snp_bottom)
            make.width.equalTo(retweeted_status.snp_width)
        }
        reposts_count.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(comments_count.snp_top)
            make.left.equalTo(comments_count.snp_right)
            make.bottom.equalTo(comments_count.snp_bottom)
            make.width.equalTo(retweeted_status.snp_width)
            
            make.right.equalTo(self.snp_right)
        }
        
        
        // 添加分割线
        let sep1 = sepView()
        let sep2 = sepView()
        
        addSubview(sep1)
        addSubview(sep2)
        
        let w = 0.5
        let scale = 0.4
        
        sep1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweeted_status.snp_right)
            make.centerY.equalTo(retweeted_status.snp_centerY)
            make.height.equalTo(comments_count.snp_height).multipliedBy(scale)
            make.width.equalTo(w)
        }
        sep2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(comments_count.snp_right)
            make.centerY.equalTo(comments_count.snp_centerY)
            make.height.equalTo(comments_count.snp_height).multipliedBy(scale)
            make.width.equalTo(w)
        }
    }

    
    /// 设置分离视图
    private func sepView() -> UIView {
        let view = UIView()
        view.backgroundColor = UIColor.darkGrayColor()
        return view
    }
}
